package com.example.star.utils;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;

import com.bumptech.glide.Glide;
import com.example.star.R;

public class ImageZoomDialogFragment extends DialogFragment {
    private static final String ARG_IMAGE_URL = "image_url";

    public static ImageZoomDialogFragment newInstance(String imageUrl) {
        ImageZoomDialogFragment fragment = new ImageZoomDialogFragment();
        Bundle args = new Bundle();
        args.putString(ARG_IMAGE_URL, imageUrl);
        fragment.setArguments(args);
        return fragment;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.dialog_image_zoom, container, false);
        ImageView zoomImageView = view.findViewById(R.id.zoom_image_view);
        String imageUrl = getArguments().getString(ARG_IMAGE_URL);

        Glide.with(this)
                .load(imageUrl)
                .placeholder(R.drawable.register)
                .error(R.drawable.register)
                .into(zoomImageView);

        return view;
    }
}